package com.jia.leetCode;

/**
 * @program: Leetcode
 * @description:
 * @author: STU756
 * @create: 2020-08-20 11:37
 */
public class Pro0082 {
    public ListNode deleteDuplication(ListNode head) {
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode pre = dummy;
        ListNode cur = dummy;
        while(cur.next!=null) {
            ListNode p = cur.next;
            //找到重复最后一个节点
            while(p.next!=null && p.val == p.next.val){
                p = p.next;
            }
            if(cur.next == p) {
                //没重复
                cur = p;
            }else {
                //有重复
                cur.next = p.next;
            }

        }
        return dummy.next;
    }
}
